﻿using System.Data.Entity;
using System.Data.SqlServerCe;

namespace PhysioControls.Model
{
    public class Project : DbContext
    {
        #region Fields

        public DbSet<Page> Pages { get; set; }

        #endregion

        #region Methods

        public void AddPage(Page page)
        {
            Pages.Add(page);
        }

        public bool ContainsPage(Page page)
        {
            foreach (var p in Pages)
            {
                if (p == page) return true;
            }
            return false;
        }

        public void SaveToSqlCe(string path)
        {
            var connString = string.Format("Data Source={0}", path);
            SqlCeConnectionStringBuilder sb = new SqlCeConnectionStringBuilder(connString);

            Database.Connection.ConnectionString = sb.ToString();
            SaveChanges();
        }

        #endregion
    }
}
